//Tue Jun 21 23:46:45 CDT 2011
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
 
using namespace std;
 
class TheAlmostLuckyNumbersDivTwo {
public:
 
  bool lucky(int n) {
    int ret = 0;
    stringstream s;
    s << n;
    string ss = s.str();
    for (int i = 0; i < ss.size(); i++) {
      if (ss[i] != '4' && ss[i] != '7')
        ret++;
    }
    if (ret > 1)
      return false;
    return true;
  }
 
  int find(int a, int b) {
    int count = 0;
    for (int i = a; i <= b; i++) {
      if (lucky(i)) {
        count++;
  //      cout << i << endl;
      }
    }
    return count;
  }
};
